const dictLists = {
  PROTOCOL_STATUS: [
    { code: '02', name: '生效中' },
    { code: '03', name: '已失效' }
  ],
  PLACE_ORDER_STATUS: [
    { code: '0', name: '预购单' },
    { code: '1', name: '待接单' },
    { code: '2', name: '待发货' },
    { code: '3', name: '已部分发货' },
    { code: '4', name: '已发货' },
    { code: '5', name: '已完成' },
    { code: '6', name: '退款|售后' },
    { code: '9', name: '已取消' }
  ],
  deliverType: [
    { code: '0', name: '待确认收货' },
    { code: '1', name: '已确认收货' }
  ],
  orderInvoiceType: [
    { code: '2', name: '增值税专用发票' },
    { code: '3', name: '电子票' }
  ],
  orderGoodsRate: [
    { code: '5', name: '五星' },
    { code: '4', name: '四星' },
    { code: '3', name: '三星' },
    { code: '2', name: '二星' },
    { code: '1', name: '一星' }
  ],
  afterSaleType: [
    { code: '1', name: '退货' },
    { code: '2', name: '换货' }
  ],
  afterSaleSimpleStatus: [
    { code: '10', name: { status: '#F759AB', text: '待处理' } },
    { code: '20', name: { status: '#FF4D4F', text: '已取消' } },
    { code: '30', name: { status: '#FF7A45', text: '售后处理中' } },
    { code: '40', name: { status: '#73D13D', text: '已完成' } }
  ],
  invoiceType: [
    { code: '1', name: '增值税普通发票' },
    { code: '2', name: '增值税专用发票' }
  ],
  invoiceMedia: [
    { code: '1', name: '电子发票' },
    { code: '2', name: '纸质发票' }
  ],
  invoiceStatus: [
    { code: '10', name: { status: 'processing', text: '待开票' } },
    { code: '11', name: { status: 'error', text: '已开票，待客户确认' } },
    { code: '12', name: { status: 'success', text: '已完成' } },
    { code: '13', name: { status: 'error', text: '客户申请退票，待审核' } },
    { code: '14', name: { status: 'error', text: '退票待处理' } },
    { code: '15', name: { status: 'error', text: '已退票' } },
    { code: '16', name: { status: 'error', text: '退票申请已拒绝' } },
    { code: '17', name: { status: 'error', text: '开票申请已拒绝' } }
  ],
  contractStatus: [
    { code: '1', name: { status: 'success', text: '待供应商确认' } },
    { code: '2', name: { status: 'success', text: '待采购确认' } },
    { code: '3', name: { status: 'default', text: '已签订' } },
    { code: '4', name: { status: 'warning', text: '已作废' } }
  ],
  orderStatus: [
    { code: '0', name: { text: '预购', status: '#ccc' } },
    { code: '1', name: { text: '待接单', status: '#F759AB' } },
    { code: '2', name: { text: '待发货', status: '#FF7A45' } },
    { code: '3', name: { text: '已部分发货', status: '#FFA940' } },
    { code: '4', name: { text: '已发货', status: '#36CFC9' } },
    { code: '5', name: { text: '已完成', status: '#73D13D' } },
    { code: '6', name: { text: '已退换货', status: '#597EF7' } },
    { code: '9', name: { text: '已取消', status: '#FF4D4F' } }
  ],
  billStatus: [
    { code: '1', name: '待供应商确认' },
    { code: '2', name: '待采购人确认' },
    { code: '3', name: '已完成' }
  ],
  afterSaleDetailStatus: [
    { code: '1', name: '无售后' },
    { code: '2', name: '有退货' },
    { code: '3', name: '换货' }
  ],
  serviceFeeType: [
    { code: '1', name: '交易手续费' },
    { code: '2', name: '功能服务费' },
    { code: '3', name: '信息订阅费' }
  ],
  settleStatus: [
    { code: '1', name: '未结算' },
    { code: '2', name: '已结算' }
  ],
  invoice_status: [
    { code: '1', name: '未开票' },
    { code: '2', name: '开票处理中' },
    { code: '3', name: '已开票' }
  ],

  payStatus: [
    { code: '1', name: '未缴纳' },
    { code: '2', name: '已缴纳' }
  ],
  bondType: [{ code: '1', name: '交易保证金' }],

  userStatus: [
    { code: '1', name: { status: 'success', text: '启用' } },
    { code: '2', name: { status: 'error', text: '停用' } }
  ],

  roleStatus: [
    { code: '0', name: { text: '启用', status: 'success' } },
    { code: '1', name: { text: '停用', status: 'error' } }
  ],
  companyType: [
    { code: '1', name: '国营' },
    { code: '2', name: '私营' },
    { code: '3', name: '外资' },
    { code: '4', name: '中外合资' },
    { code: '9', name: '其他' }
  ],
  employeeNumber: [
    { code: '1', name: '1-50人' },
    { code: '2', name: '51-100人' },
    { code: '3', name: '101-300人' },
    { code: '4', name: '301-500人' },
    { code: '5', name: '501-1000人' },
    { code: '6', name: '1000人以上' }
  ],
  taxpayer: [
    { code: true, name: '是' },
    { code: false, name: '否' }
  ],
  regCurrency: [
    { code: '1', name: '人民币' },
    { code: '2', name: '港币' },
    { code: '3', name: '欧元' },
    { code: '4', name: '美元' },
    { code: '5', name: '日元' },
    { code: '6', name: '新加坡元' },
    { code: '7', name: '英镑' },
    { code: '8', name: '法国法郎' },
    { code: '9', name: '德国马克' },
    { code: '10', name: '荷兰盾' },
    { code: '11', name: '意大利里拉' },
    { code: '12', name: '加拿大元' },
    { code: '13', name: '澳大利亚元' },
    { code: '14', name: '西班牙比塞塔' },
    { code: '15', name: '泰国铢' }
  ],

  stockReduceMethod: [
    { code: '1', name: '拍下减库存' },
    { code: '2', name: '付款减库存' }
  ],

  supportAfterSaleService: [
    { code: '1', name: '支持买家申请换货' },
    { code: '2', name: '7天无理由退货' }
  ],
  inquiryPriceType: [
    { code: '1', name: '询比价' },
    { code: '2', name: '竞价' },
    { code: '3', name: '定点' }
  ],
  auditStatus: [
    { code: '0', name: '待处理' },
    { code: '1', name: '通过' },
    { code: '2', name: '不通过' }
  ],
  iconfontActionName: [
    { code: '3001', name: '竞', icon: 'jing' },
    { code: '3005', name: '竞', icon: 'jing' },
    { code: '3007', name: '竞', icon: 'jing' },
    { code: '3009', name: '中', icon: 'zhong' },
    { code: '3011', name: '废', icon: 'fei' },
    { code: '3101', name: '协', icon: 'xie' }
  ],
  catalogAuditStatus: [
    { code: '0', name: '未处理' },
    { code: '1', name: '通过' },
    { code: '2', name: '驳回' }
  ],
  goodAuditStatus: [
    { code: '0', name: '未提交' },
    { code: '1', name: '待审核' },
    { code: '2', name: '已上架' },
    { code: '3', name: '审核未通过' },
    { code: '4', name: '已下架' }
  ],
  goodsStatusType: [
    { code: '1', name: '销售中' },
    { code: '2', name: '已售罄' },
    { code: '3', name: '已下架' }
  ],
  protocolSource: [
    { code: '01', name: '电子招投标' },
    { code: '02', name: '询比价' },
    { code: '03', name: '竞价' },
    { code: '04', name: '搓商' },
    { code: '05', name: '单一来源' },
    { code: '06', name: '协议共享' },
    { code: '99', name: '其他' }
  ],
  taxDemand: [
    { code: '01', name: '含税' },
    { code: '02', name: '不含税' }
  ],
  paymentTerms: [
    { code: '01', name: '到账结算' },
    { code: '02', name: '订单结算' }
  ],
  shippingCostTerms: [
    { code: '01', name: '含运费' },
    { code: '02', name: '不含运费' }
  ],
  invoiceTerms: [
    { code: '01', name: '增值税专用发票' },
    { code: '02', name: '增值税普通发票' },
    { code: '03', name: '不用发票' }
  ],
  deliveryDateTerms: [
    { code: '01', name: '按交货日期' },
    { code: '02', name: '按下单后交货天数' }
  ],
  supplyType: [
    { code: '1', name: '协议供货' },
    { code: '2', name: '自营供货' }
  ],
  certLevel: [
    { code: '0', name: '未认证' },
    { code: '1', name: '已认证' }
  ],
  joinStatus: [
    { code: '0', name: '申请加入' },
    { code: '1', name: '申请中' },
    { code: '2', name: '已加入' }
  ],
  logOptType: [
    { code: '11', name: '登录成功' },
    { code: '12', name: '登录失败' },
    { code: '13', name: '账号锁定' },
    { code: '14', name: '登出' },
    { code: '15', name: '修改密码' },
    { code: '16', name: '修改个人信息' },
    { code: '21', name: '协议创建' },
    { code: '22', name: '协议更新' },
    { code: '23', name: '协议作废' },
    { code: '24', name: '协议恢复' },
    { code: '211', name: '商品申请上架' },
    { code: '212', name: '商品申请上架撤回' },
    { code: '213', name: '商品申请上架通过' },
    { code: '214', name: '商品申请上架失败' },
    { code: '221', name: '商品申请下架' },
    { code: '222', name: '商品申请下架通过' },
    { code: '223', name: '商品申请下架失败' },
    { code: '224', name: '采购商品下架通知' }
  ]
}

export function dictService (v, dictKeys) {
  for (let i in dictKeys) {
    let key = dictKeys[i]
    let arr = dictLists[key]
    let map = {}
    for (let item of arr) {
      map[item.code] = item.name
    }
    v.$set(v.dataDictMap, key, map)
    v.$set(v.dataDictList, key, arr)
  }
}

export function mapDict (dictKeys) {
  let dataDictMap = {}
  let dataDictList = {}
  for (let i in dictKeys) {
    let key = dictKeys[i]
    let arr = dictLists[key]
    let map = {}
    for (let item of arr) {
      map[item.code] = item.name
    }
    dataDictMap[key] = map
    dataDictList[key] = arr
  }
  console.log(dataDictMap)
  return { dataDictMap: dataDictMap, dataDictList: dataDictList }
}
